Collect library/binary names when documenting even if a spec was given
authorSebastian Dröge <sebastian@centricular.com>
Mon, 9 Jan 2017 10:52:56 +0000 (12:52 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 9 Jan 2017 10:52:56 +0000 (12:52 +0200)
This seems more consistent and generally should work better.

src/cargo/ops/cargo_doc.rs

index 6817cca3be5183a476885c125aa68fddfca3ac36..f02ec220704eac0e71ce5f4e33338aaef0f5f769 100644 (file)
@@ -34,21 +34,19 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> {
 
     let mut lib_names = HashSet::new();
     let mut bin_names = HashSet::new();
-    if specs.is_empty() {
-        for package in &pkgs {
-            for target in package.targets().iter().filter(|t| t.documented()) {
-                if target.is_lib() {
-                    assert!(lib_names.insert(target.crate_name()));
-                } else {
-                    assert!(bin_names.insert(target.crate_name()));
-                }
+    for package in &pkgs {
+        for target in package.targets().iter().filter(|t| t.documented()) {
+            if target.is_lib() {
+                assert!(lib_names.insert(target.crate_name()));
+            } else {
+                assert!(bin_names.insert(target.crate_name()));
             }
-            for bin in bin_names.iter() {
-                if lib_names.contains(bin) {
-                    bail!("cannot document a package where a library and a binary \
-                           have the same name. Consider renaming one or marking \
-                           the target as `doc = false`")
-                }
+        }
+        for bin in bin_names.iter() {
+            if lib_names.contains(bin) {
+                bail!("cannot document a package where a library and a binary \
+                       have the same name. Consider renaming one or marking \
+                       the target as `doc = false`")
             }
         }
     }